package org.example.spring.Result;

import lombok.Data;

import java.io.Serial;
import java.io.Serializable;

@Data
public class Result<T> implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    private Integer code;
    private String msg;
    private T data;

    //成功返回
    public static <T> Result<T> success(T obj) {
        Result<T> result = new Result<>();
        result.code = 1;
        result.msg = "请求成功";
        result.data = obj;
        return result;
    }
    public static <T> Result<T> success() {
        Result<T> result = new Result<>();
        result.code = 1;
        result.msg = "请求成功";
        return result;
    }

    public static <T> Result<T> error(String msg) {
        Result<T> result = new Result<>();
        result.code = 0;
        result.msg = msg;
        return result;
    }



}
